import request from 'umi-request';

export async function queryRule(params = {}) {
  return request('/hr-ssc/api/api-admin/salary/getSalaryBandList', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      orgSystemId: params.orgSystemId,
      orgLineId: params.orgLineId,
      jobLevelId: params.jobLevelId,
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function addSalaryBand(params) {
  return request('/hr-ssc/api/api-admin/salary/addSalaryBand', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then(( res) => {
    return res.flag;
  });
}

export async function updateSalaryBand(params) {
  return request('/hr-ssc/api/api-admin/salary/updateSalaryBand', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res.flag;
  });
}

export async function deleteSalaryBand(id) {
  return request(`/hr-ssc/api/api-admin/salary/deleteSalaryBand/${id}`, {
    method: 'delete',
  }).then((res) => {
    return res.data;
  });
}
